package gui;

/*
 * Esse arquivo é parte do Software new Recicle
 * 
 * Copyright (C) 2011-$AnoCorrente$ Eduardo Moreira Barbosa
 * Copyright (C) 2011-$AnoCorrente$ João dos Santos Gonçalves
 * Copyright (C) 2011-$AnoCorrente$ Lucas Ximenes da Fonseca
 * 
 * new Recicle é um Software Livre: Você pode redistribuí-lo e/ou modificá-lo
 * de acordo com os termos da Licença Pública Geral GNU (GNU General Public License)
 * conforme publicada pela Free Software Foundation (FSF). Essa permissão é atribuída
 * na versão 3 da Licença, ou (na sua opinião) qualquer versão.
 * 
 * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este programa,
 * se não, escreva para a Fundação do Software Livre(FSF) Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA  02110-1301  USA
 * 
 * Se você tiver alguma dúvida e/ou quiser dar suporte ao desenvolvimento, favor entrar em
 * contato nos e-mails <barbosa.edrd@gmail.com>, <john.jsg@hotmail.com>, <lxf.lucas@gmail.com>.
 */

import bd.BancoDeDados;
import bd.BancoVoluntario;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.KeyStroke;
import outros.Cpf;
import rh.Voluntario;

public class CadastrarVoluntario extends javax.swing.JDialog {

    protected static CadastrarVoluntario dialog;
    private static boolean isEdicao = false;
    private static String selecionado;
    
    public CadastrarVoluntario(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        
        defineIconesFrame(); // Icone da JFrame

        String cancelName = "cancel";
        InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
        inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), cancelName); 
    }
    
    public void setIsEdicao(boolean is) {
        isEdicao = is;
    }
    
    public void setSelecionado(String selecionado) {
        CadastrarVoluntario.selecionado = selecionado;
    }
    
    private void cVoluntario() {
       
        if ( nomeText.getText().length() > 3) {
            if (senhaText.getText().equals(senhaRText.getText())) {
                
                if (Cpf.calculaCpf(cpfText.getText())) {
                    
                    String sex = sexoText.getText().toUpperCase();
                    if (sex.equals("M") || sex.equals("F")) {
                        
                        if (!((emailText.getText().length() < 4)
                                || !emailText.getText().contains("@")
                                || !emailText.getText().contains("."))) {
                            
                            if ( EscolheImagem.validacao() == true ) {
                                
                                Voluntario.getVoluntario().setNome(nomeText.getText());
                                Voluntario.getVoluntario().setSenha(senhaText.getText());
                                Voluntario.getVoluntario().setSexo(sexoText.getText());
                                Voluntario.getVoluntario().setCpf(cpfText.getText());
                                Voluntario.getVoluntario().setTelefone(telefoneText.getText());
                                Voluntario.getVoluntario().setCelular(celularText.getText());
                                Voluntario.getVoluntario().setEmail(emailText.getText());
                                Voluntario.getVoluntario().setImagem(imagemPath.getText());
                                
                                BancoDeDados bancoDeDados = new BancoDeDados();
                                bancoDeDados.conectarBanco();
                                
                                BancoVoluntario bancoVoluntario = new BancoVoluntario();
                                bancoVoluntario.cadastrar();

                                /*
                                 * Atualiza os botões.
                                 */
                                NewRecicle.atualizaBotoes();
                                
                                
                                this.dispose();
                                
                            } else {
                                avisos.setText("Aviso!: Imagem inválida! Escolha um arquivo: JPG ou PNG...");
                            }
                        } else {
                            avisos.setText("Aviso!: O e-mail é inválido, verifique se esta correto...");
                        }
                        
                    } else {
                        avisos.setText("Aviso!: Sexo deve ter apenas um caractere. Ex.: M");
                    }
                } else {
                    avisos.setText("Aviso!: CPF inválido! Confira e tente novamente...");
                }
                
            } else {
                avisos.setText("Aviso!: Senhas diferentes! Por favor, tente novamente...");
            }
        } else {
           avisos.setText("Aviso!: Nome curto ou em branco! Deve ter pelo menos 4 letras...");
        }
    }
    
    private void eVoluntario(String selecionado){
        if ( senhaText.getText().equals(senhaRText.getText()) ) {
            

            if ( Cpf.calculaCpf( cpfText.getText() ) ) {
                
                String sex = sexoText.getText().toUpperCase();
                if ( sex.equals("M") || sex.equals("F")) {
                    
                    if ( ! ((emailText.getText().length() < 4) ||
                            !emailText.getText().contains("@") ||
                            !emailText.getText().contains("."))  ) {
                        
                        if ( EscolheImagem.validacao() == true ) {
                            
                            Voluntario voluntario = new Voluntario();

                            voluntario.setNome( nomeText.getText() );
                            voluntario.setSenha( senhaText.getText() );
                            voluntario.setSexo( sexoText.getText() );
                            voluntario.setCpf( cpfText.getText() );
                            voluntario.setTelefone( telefoneText.getText() );
                            voluntario.setCelular( celularText.getText() );
                            voluntario.setEmail( emailText.getText() );
                            voluntario.setImagem( imagemPath.getText() );

                            BancoDeDados bancoDeDados = new BancoDeDados();
                            bancoDeDados.conectarBanco();
                            
                            BancoVoluntario bancoVoluntario = new BancoVoluntario();
                            bancoVoluntario.alterar(voluntario, selecionado);
                            
                            /*
                             * Atualizar os botões
                             */
                            NewRecicle.atualizaBotoes();
                            /*
                             * Reinicia o valor da variavel, evitando erros
                             */
                            isEdicao = false;
                                                        
                            this.dispose();
                            
                        } else {
                            avisos.setText("Aviso!: Imagem inválida! Escolha um arquivo: JPG ou PNG...");
                        }
                    } else {
                        avisos.setText("Aviso!: O e-mail é inválido, verifique se esta correto...");
                    }
                    
                } else {
                avisos.setText("Aviso!: Sexo deve ter apenas um caractere. Ex.: M");
                }
            } else {
                avisos.setText("Aviso!: CPF inválido! Confira e tente novamente...");
            }

        } else {
            avisos.setText("Aviso!: Senhas diferentes! Por favor, tente novamente...");
        }
    }
    
    /**
     * Na edição de um voluntário ele serve para jogar os dados do
     * voluntário que foi selecionado para ser editado.
     * @param nome do voluntário registrado no banco de dados.
     * @param senha do voluntário.
     * @param cpf do voluntário.
     * @param sexo do voluntário.
     * @param telefone do voluntário.
     * @param celular do voluntário.
     * @param email  do voluntário.
     */
    public void editandoVoluntario(String nome, String senha, String cpf, String sexo,
            String telefone, String celular, String email) {
        
        nomeText.setText( nome );
        senhaText.setText( senha );
        senhaRText.setText( senha );
        cpfText.setText( cpf );
        sexoText.setText( sexo );
        telefoneText.setText( telefone );
        celularText.setText( celular );
        emailText.setText( email );
    }

    private void defineIconesFrame(){
        try {
            //Setando o Icone do Frame Principal
            this.setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("/imagens/ervilha/Logo.png")));
        } catch (Exception e){
            e.printStackTrace();
        }
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        imagemBotao = new javax.swing.JButton();
        avisos = new javax.swing.JLabel();
        nomeText = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        sexoText = new javax.swing.JFormattedTextField();
        senhaRText = new javax.swing.JPasswordField();
        jLabel10 = new javax.swing.JLabel();
        telefoneText = new javax.swing.JFormattedTextField();
        imagemPath = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        celularText = new javax.swing.JFormattedTextField();
        jLabel4 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        cpfText = new javax.swing.JFormattedTextField();
        emailText = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        senhaText = new javax.swing.JPasswordField();
        jLabel1 = new javax.swing.JLabel();
        okButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Cadastrado de Voluntário");
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                closeDialog(evt);
            }
        });

        imagemBotao.setText("Escolher imagem");
        imagemBotao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                imagemBotaoActionPerformed(evt);
            }
        });

        avisos.setFont(new java.awt.Font("Tahoma", 1, 12));
        avisos.setForeground(new java.awt.Color(204, 0, 0));
        avisos.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        avisos.setText("#");

        nomeText.setFont(new java.awt.Font("Tahoma", 0, 14));

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 13));
        jLabel2.setText("Sexo: *");

        jLabel5.setFont(new java.awt.Font("Tahoma", 0, 13));
        jLabel5.setText("Redigite a senha: *");

        try {
            sexoText.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("*")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        sexoText.setHorizontalAlignment(javax.swing.JTextField.CENTER);

        senhaRText.setFont(new java.awt.Font("Tahoma", 0, 14));

        jLabel10.setFont(new java.awt.Font("Tahoma", 0, 13));
        jLabel10.setText("Imagem: *");

        try {
            telefoneText.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        imagemPath.setEditable(false);
        imagemPath.setFont(new java.awt.Font("Tahoma", 0, 14));

        jLabel6.setFont(new java.awt.Font("Tahoma", 0, 13));
        jLabel6.setText("* Campo obrigatório!");

        jLabel7.setFont(new java.awt.Font("Tahoma", 0, 13));
        jLabel7.setText("Telefone:");

        try {
            celularText.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("(##)####-####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }

        jLabel4.setFont(new java.awt.Font("Tahoma", 0, 13));
        jLabel4.setText("CPF:*");

        jLabel8.setFont(new java.awt.Font("Tahoma", 0, 13));
        jLabel8.setText("Celular:");

        try {
            cpfText.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("###.###.###-##")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        cpfText.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cpfTextActionPerformed(evt);
            }
        });

        emailText.setFont(new java.awt.Font("Tahoma", 0, 14));

        jLabel9.setFont(new java.awt.Font("Tahoma", 0, 13));
        jLabel9.setText("E-mail:*");

        jLabel3.setFont(new java.awt.Font("Tahoma", 0, 13));
        jLabel3.setText("Senha: *");

        senhaText.setFont(new java.awt.Font("Tahoma", 0, 14));

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 13));
        jLabel1.setText("Nome: *");

        okButton.setFont(new java.awt.Font("Tahoma", 1, 18));
        okButton.setText("Confirmar");
        okButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                okButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(senhaText, javax.swing.GroupLayout.PREFERRED_SIZE, 255, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(120, 120, 120)
                                .addComponent(jLabel5)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(senhaRText, javax.swing.GroupLayout.PREFERRED_SIZE, 261, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(nomeText, javax.swing.GroupLayout.PREFERRED_SIZE, 752, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(309, 309, 309)
                        .addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel6)
                                .addGap(266, 266, 266)
                                .addComponent(avisos, javax.swing.GroupLayout.PREFERRED_SIZE, 435, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(telefoneText, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(cpfText, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(sexoText, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(imagemPath, javax.swing.GroupLayout.PREFERRED_SIZE, 281, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(imagemBotao, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                                        .addComponent(celularText, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(emailText, javax.swing.GroupLayout.PREFERRED_SIZE, 363, javax.swing.GroupLayout.PREFERRED_SIZE)))))))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(nomeText, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(senhaRText, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(senhaText, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(cpfText, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel2)
                        .addComponent(sexoText, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel10)
                        .addComponent(jLabel4))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(imagemPath, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(imagemBotao, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(11, 11, 11)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(telefoneText, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9)
                    .addComponent(jLabel8)
                    .addComponent(celularText, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(emailText, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(47, 47, 47)
                .addComponent(okButton, javax.swing.GroupLayout.DEFAULT_SIZE, 34, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(avisos, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        getRootPane().setDefaultButton(okButton);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
       
    }//GEN-LAST:event_closeDialog

    private void imagemBotaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_imagemBotaoActionPerformed
        imagemPath.setText(EscolheImagem.imagemPath());
    }//GEN-LAST:event_imagemBotaoActionPerformed

    private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
        if (isEdicao == false) {
            cVoluntario();
        } else if (isEdicao){
            eVoluntario(selecionado);
        }
    }//GEN-LAST:event_okButtonActionPerformed

    private void cpfTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cpfTextActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_cpfTextActionPerformed
    
    public static void main(String args[]) {
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(CadastrarVoluntario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(CadastrarVoluntario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(CadastrarVoluntario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(CadastrarVoluntario.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                dialog = new CadastrarVoluntario(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel avisos;
    private javax.swing.JFormattedTextField celularText;
    private javax.swing.JFormattedTextField cpfText;
    private javax.swing.JTextField emailText;
    private javax.swing.JButton imagemBotao;
    private javax.swing.JTextField imagemPath;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField nomeText;
    private javax.swing.JButton okButton;
    private javax.swing.JPasswordField senhaRText;
    private javax.swing.JPasswordField senhaText;
    private javax.swing.JFormattedTextField sexoText;
    private javax.swing.JFormattedTextField telefoneText;
    // End of variables declaration//GEN-END:variables
}